#include <cctype>
#include <iostream>
using namespace std;

int main() {
    string str;
    getline(cin, str);
    char s;
    char s_;
    cin >> s;

    // if(s >= 65 && s <= 90)
    //     s_ = s + 32;
    // else
    //     s_ = s - 32;

    if(isupper(s))
        s_ = tolower(s);
    else
        s_ = toupper(s);

    int count = 0;
    for(auto& e : str)
    {
        if(e == s || e == s_)
            count++;
    }
    
    cout << count << endl;
    return 0;
}
